<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <head th:include="commom::title('门诊管理系统')"></head>
</head>

<body>
<div class="layuimini-container">
    <div class="layuimini-main">

        <div class="layui-inline">
            <button type="submit" id="ss" class="layui-btn layui-btn-primary"  lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 叫号 </button>
        </div>


    </div>
</div>
<!--<script th:src="@{/static/lib/layui-v2.5.5/layui.js}" charset="utf-8"></script>-->
<!--<script>-->
<!--    layui.use(['form', 'table','layer','laypage'], function () {-->
<!--        const $ = layui.jquery,-->
<!--            form = layui.form,-->
<!--            layer = layui.layer,-->
<!--            table = layui.table;-->

<!--        table.render({-->
<!--            elem: '#currentTableId',-->
<!--            url: '/root/call',-->
<!--            limits: [3, 5, 10, 20],-->
<!--            limit: 10,-->
<!--            page: true,-->
<!--            toolbar: '#toolbarDemo',-->
<!--            defaultToolbar: ['filter', 'exports', 'print'],-->
<!--            cols: [-->
<!--                [-->
<!--                {type: "checkbox", field: 'center'},-->
<!--                {field: 'patient_id', width: 100, title: '病人ID', sort: true, align:'center'},-->
<!--                {field: 'patient_name', width: 120, title: '病人名字', align:'center'},-->
<!--                {field: 'position', width: 100, title: '位置', align:'center'},-->
<!--                ]-->
<!--            ],-->
<!--            id: 'testReload'-->
<!--        });-->




<!--    });-->
<!--</script>-->

<script th:src="@{/static/lib/layui-v2.5.5/layui.js}" charset="utf-8"></script>
<script>
    layui.use(['form', 'table','layer','laypage'], function () {

        /**
         * toolbar监听事件
         */
        table.on('toolbar(currentTableFilter)', function (obj) {
            const data = obj.data //获得当前行数据
                , layEvent = obj.event; //获得 lay-event 对应的值
            if (obj.event === 'add') {  // 监听添加操作
                const index = layer.open({
                    title: '新建',
                    type: 2,
                    shade: 0.2,
                    maxmin: true,
                    shadeClose: true,
                    area: ['30%', '70%'],
                    content: '/view/addExam'
                });
                $(window).on("resize", function () {
                    layer.full(index);
                });
            } else if (obj.event === 'delete') {
                var checkStatus = table.checkStatus('testReload');
                var selectCount = checkStatus.data.length;
                console.log(checkStatus);
                console.log(selectCount);
                if(selectCount == 0){
                    layer.msg('批量删除至少选中一项数据',function(){});
                    return false;
                }
                layer.confirm('确定删除行？',function(index){
                    layer.close(index);
                    // 加载层
                    index = layer.load(1, {shade: [0.1,'#fff']});
                    var listStr="";
                    for(var i=0; i<selectCount; i++){
                        listStr = listStr + "," + checkStatus.data[i].id;
                    }
                    $.ajax({
                        type:'post',
                        data:{"listStr":listStr},
                        url:'/root/batchDelHealth',
                        success:function(data){
                            layer.close(index);
                            layer.msg(data.msg);
                            table.reload('testReload');
                        }
                    });
                });
            }
        });



        function del(id,obj,index){
            $.ajax({
                url:'/root/delHealth?id='+id,
                dataType:'json',
                type:'post',
                success:function (data) {
                    obj.del();
                    layer.msg(data.msg,{icon: 1,time: 1000});
                    layer.close(layui.index);
                    table.reload('testReload');
                }
            })
        }


    });
</script>
<script>
  // 使用jQuery绑定按钮点击事件
  $('#ss').click(function() {
    console.log('按钮被点击了');
    $.ajax({
      url: '/root/call', // 替换为你的请求URL
      type: 'POST', // 请求类型，可以根据实际情况修改
      data: {
      },
      success: function(data) {
        // 请求成功后的处理逻辑
        layer.open({
          type: 1,
          title: '提示',
          content: '已叫号',
          area: '300px',
          btn: ['确定'],
          yes: function(index, layero) {
            layer.close(index);
          }
        });
      },
      error: function(xhr, status, error) {
        // 请求失败后的处理逻辑
        console.log('请求失败');
      }
    });
  });

</script>

</body>
</html>
